package org.itsolutions.javaBackup.gui.web;

import org.itsolutions.javaBackup.gui.web.admin.AdminApplicationServlet;
import org.itsolutions.javaBackup.gui.web.admin.PageFilterAdmin;

import com.google.inject.Inject;
import com.google.inject.Injector;
import com.google.inject.servlet.GuiceServletContextListener;
import com.google.inject.servlet.ServletModule;

/**
 * 
 * @author Tomas Fecko
 */
public class ServletContextListener extends GuiceServletContextListener {

    private Injector mInjector;

    /**
     * 
     * @param pInjector injector
     */
    @Inject ServletContextListener(Injector pInjector) {
        mInjector = pInjector;
    }

    @Override
    protected final Injector getInjector() {
        ServletModule module = new ServletModule() {
            @Override
            protected void configureServlets() {
//                serve("/administration").with(AdministrationApplicationServlet.class);
                serve("/*").with(AdminApplicationServlet.class);

                filterRegex("/admin.*").through(PageFilterAdmin.class);
            }
        };
        return mInjector.createChildInjector(module);
    }
}





